import { Card, Tabs } from 'antd'
import React, { Component } from 'react'
import '../../assets/css/login.css'
import PasswdForm from './PasswdForm'
import MobileForm from './MobileForm'
import { withRouter } from 'react-router-dom'
// import必须在const前面
const { TabPane } = Tabs
class Index extends Component {
  constructor(props) {
    super(props)
    // 判断用户已经登录就跳转到dashboard欢迎页面
    const jwt = localStorage.getItem('jwt')
    if (jwt) {
      // console.log(this.props);
      this.props.history.push('/dashboard/welcome')
    }
  }
  render() {
    return (
      <div id="container">
        <Card id="login-card">
          <Tabs defaultActiveKey="1" size="large" centered>
            <TabPane tab="密码登录" key="1">
              <PasswdForm />
            </TabPane>
            <Tabs.TabPane tab="短信登录" key="2">
              <MobileForm />
            </Tabs.TabPane>
          </Tabs>
        </Card>
      </div>
    )
  }
}
export default withRouter(Index)